package com.lagou;

import com.lagou.service.Method;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.time.Instant;
import java.util.concurrent.*;

public class ConsumerApplication {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        context.start();
        Method method = context.getBean("Method", Method.class);
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        // 起始时间
        long startMills = Instant.now().toEpochMilli();
        for (int i = 0; i < 2500; i++) {
            executorService.execute(new RandomMathod(method));
        }
        executorService.shutdown();
        // 终止时间
        long endMills = Instant.now().toEpochMilli();
        System.out.println("-----总耗时" + (endMills - startMills) + "-----");
    }

}
